﻿namespace Guia.Elements
{
    using System;
    using System.Windows.Automation;
    using Guia.Locator;

    /// <summary>
    /// This class represents a DataGrid-element of the ListView with containing GridView.
    /// </summary>
    public class DataGrid_ListView : AbstractDataGrid
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DataGrid_ListView"/> class.
        /// </summary>
        /// <param name="automationElement">The automation element.</param>
        public DataGrid_ListView(AutomationElement automationElement)
            : base(automationElement)
        {
        }

        /// <summary>
        /// Gets the default-condition to find a control by its type.
        /// </summary>
        public static SearchCondition ControlTypeCondition
        {
            get { return SearchCondition.ByControlType(ControlType.DataGrid).And(SearchCondition.ByClassName("ListView")); }
        }

        /// <summary>
        /// Gets a list of the avaiable rows.
        /// </summary>
        public DataGridRow_ListView[] Rows
        {
            get { return this.GetRows<DataGridRow_ListView>(); }
        }

        /// <summary>
        /// Gets the cell with the given coordinates.
        /// </summary>
        /// <param name="row">The nr of the row, beginning at zero.</param>
        /// <param name="column">The nr of the column, beginning at zero.</param>
        /// <returns>An instance of DataGridCell.</returns>
        /// <exception cref="ArgumentOutOfRangeException">This exception is thrown if no cell exists at the given position.</exception>
        public DataGridCell_ListView this[int row, int column]
        {
            get
            {
                return this.GetCell<DataGridCell_ListView>(row, column);
            }
        }
    }
}
